package tcl.loan.system.common.handler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;

import javax.servlet.http.HttpServletRequest;
import java.text.MessageFormat;

/**
 * Created by linjianding on 2016/12/5.
 */
public class CustomHandlerExceptionResolver extends SimpleMappingExceptionResolver {
    private static Logger logger = LoggerFactory.getLogger(CustomHandlerExceptionResolver.class);

    @Override
    protected void logException(Exception ex, HttpServletRequest request) {
        //String ip = Strings.getRemoteAddr(request);
        String method = request.getMethod();
        String url = request.getRequestURI();
        String queryString = request.getQueryString();
        String error ="test";// MessageFormat.format("ip:[{0}] [{1}] [{2}{3}],发生:{4}", ip, method, url, Strings.isBlank(queryString) ? "" : "?" + queryString, ex.getMessage());
        logger.error(error, ex);
    }
}
